package com.leizhi.demo.monitor.utils;

import static com.leizhi.demo.monitor.utils.SipConstantUtil.SESSION_NAME_PLAY;
import static com.leizhi.demo.monitor.utils.SipConstantUtil.SESSION_NAME_PLAYBACK;

/**
 * @Description SIP 内容生成器
 * @Version 1.0.0-SNAPSHOT
 * @Author leizhi
 * @Date 2025/4/27 9:57
 */
public class SipContentHelperUtil {

    public static String generateRealTimeStreamInviteContent(String sessionId, String ip, Integer port, Long ssrc) {
        return "v=0\r\n" +
                "o=" + sessionId + " 0 0 IN IP4 " + ip + "\r\n" +
                "s=" + SESSION_NAME_PLAY + "\r\n" +
                "c=IN IP4 " + ip + "\r\n" +
                "t=0 0\r\n" +
                "m=video " + port + " " + "RTP/AVP 96 98 97\r\n" +
                "a=sendrecv\r\n" +
                "a=rtpmap:96 PS/90000\r\n" +
                "a=rtpmap:98 H264/90000\r\n" +
                "a=rtpmap:97 MPEG4/90000\r\n" +
                "y=" + ssrc + "\r\n";
    }

    public static String generatePlaybackStreamInviteContent(String sessionId, String ip, Integer port, Integer ssrc, String startTime, String endTime) {
        return "v=0\r\n" +
                "o=" + sessionId + " 0 0 IN IP4 " + ip + "\r\n" +
                "s=" + SESSION_NAME_PLAYBACK + "\r\n" +
                "c=IN IP4 " + ip + "\r\n" +
                "t=" + startTime + " " + endTime + "\r\n" +
                "m=video " + port + " " + "RTP/AVP 96 98 97\r\n" +
                "a=recvonly\r\n" +
                "a=rtpmap:96 PS/90000\r\n" +
                "a=rtpmap:98 H264/90000\r\n" +
                "a=rtpmap:97 MPEG4/90000\r\n" +
                "y=" + ssrc + "\r\n";
    }

    public static String generateCatalogContent(String deviceId, String sn) {
        return "<?xml version=\"1.0\"?>\r\n" +
                "<Query>\r\n" +
                "<CmdType>Catalog</CmdType>\r\n" +
                "<SN>" + sn + "</SN>\r\n" +
                "<DeviceID>" + deviceId + "</DeviceID>\r\n" +
                "</Query>";
    }

}
